package models

import (
	"doctor-medicine-system/doctorrpc/doctorrpc"

	"gorm.io/gorm"
)

type Doctor struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11);not null;"`
	Password string `gorm:"type:char(32);not null;"`
}

type Shop struct {
	gorm.Model
	Name     string `gorm:"type:varchar(30);not null;"`
	Num      int    `gorm:"type:int(11);not null;"`
	Address  string `gorm:"type:varchar(50);not null;"`
	Title    string `gorm:"type:varchar(30);not null;"`
	Fans     string `gorm:"type:varchar(30);not null;"`
	DoctorId int64  `gorm:"type:int(11);not null;"`
}

func (s *Shop) ShopList(db *gorm.DB, shops []*doctorrpc.ShopList) ([]*doctorrpc.ShopList, error) {
	err2 := db.Debug().Model(&Shop{}).
		Select("shops.name , shops.num , shops.address , shops.title , shops.fans , shops.doctor_id").
		Find(&shops).Error
	return shops, err2
}
